package cn.stylefeng.guns.modular.emergency.controller;

import cn.stylefeng.guns.core.consts.ProjectConstants;
import cn.stylefeng.guns.modular.emergency.entity.RelationLevel;
import cn.stylefeng.guns.modular.emergency.pojo.request.RelationLevelRequest;
import cn.stylefeng.guns.modular.emergency.pojo.response.TreeEmergencyTypeInfo;
import cn.stylefeng.guns.modular.emergency.service.RelationLevelService;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 应急预案类型层级控制器
 *
 * @author xbz
 * @date 2023/04/24 14:58
 */
@RestController
@ApiResource(name = "应急预案类型层级")
public class RelationLevelController {

    @Resource
    private RelationLevelService relationLevelService;

    /**
     * 添加
     *
     * @author xbz
     * @date 2023/04/24 14:58
     */
    @PostResource(name = "添加", path = "/relationLevel/add",requiredPermission = false,requiredLogin = false)
    public ResponseData<RelationLevel> add(@RequestBody @Validated(RelationLevelRequest.add.class) RelationLevelRequest relationLevelRequest) {
        return relationLevelService.addEmergencyTypeNode(relationLevelRequest);
    }

    /**
     * 删除
     *
     * @author xbz
     * @date 2023/04/24 14:58
     */
    @PostResource(name = "删除", path = "/relationLevel/delete",requiredPermission = false,requiredLogin = false)
    public ResponseData<?> delete(@RequestBody @Validated(RelationLevelRequest.delete.class) RelationLevelRequest relationLevelRequest) {

        return relationLevelService.delEmergencyTypeNode(relationLevelRequest);
    }

    /**
     * 编辑
     *
     * @author xbz
     * @date 2023/04/24 14:58
     */
    @PostResource(name = "编辑", path = "/relationLevel/edit",requiredPermission = false,requiredLogin = false)
    public ResponseData<?> edit(@RequestBody @Validated(RelationLevelRequest.edit.class) RelationLevelRequest relationLevelRequest) {
        relationLevelService.edit(relationLevelRequest);
        return new SuccessResponseData<>();
    }

    /**
     * 查看详情
     *
     * @author xbz
     * @date 2023/04/24 14:58
     */
    @GetResource(name = "查看详情", path = "/relationLevel/detail",requiredPermission = false,requiredLogin = false)
    public ResponseData<RelationLevel> detail(@Validated(RelationLevelRequest.detail.class) RelationLevelRequest relationLevelRequest) {
        return new SuccessResponseData<>(relationLevelService.detail(relationLevelRequest));
    }

    /**
     * 获取列表
     *
     * @author xbz
     * @date 2023/04/24 14:58
     */
    @GetResource(name = "获取列表", path = "/relationLevel/list",requiredPermission = false,requiredLogin = false)
    public ResponseData<List<RelationLevel>> list(RelationLevelRequest relationLevelRequest) {
        return new SuccessResponseData<>(relationLevelService.findList(relationLevelRequest));
    }

    /**
     * 获取列表（带分页）
     *
     * @author xbz
     * @date 2023/04/24 14:58
     */
    @GetResource(name = "分页查询", path = "/relationLevel/page",requiredPermission = false,requiredLogin = false)
    public ResponseData<PageResult<RelationLevel>> page(RelationLevelRequest relationLevelRequest) {
        return new SuccessResponseData<>(relationLevelService.findPage(relationLevelRequest));
    }
//
//    @GetResource(name = "获取应急预案分类树", path = "/relationLevel/getTreeTypeList",requiredPermission = false,requiredLogin = false)
//    public ResponseData<List<TreeEmergencyTypeInfo>> getTreeTypeList(){
//        String tableName = ProjectConstants.EPC_EMERGENCY_TYPE_TABLE_NAME;
//        return new SuccessResponseData<>(relationLevelService.getTreeTypeList(tableName));
//    }
//
//    @GetResource(name = "获取分类叶子节点", path = "/relationLevel/getLeafNodeList",requiredPermission = false,requiredLogin = false)
//    public ResponseData<List<TreeEmergencyTypeInfo>> getLeafNodeList(){
//        String tableName = ProjectConstants.EPC_EMERGENCY_TYPE_TABLE_NAME;
//        return new SuccessResponseData<>(relationLevelService.getLeafNodeList(tableName));
//    }
}
